<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-model应对不同的表单元素</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <form @submit.prevent="demo">
            账号：<input type="text" name="username" v-model.trim="userInfo.username"/><br/>
            密码：<input type="password" name="password" v-model="userInfo.password"/><br/>
            年龄：<input type="number" name="age" v-model.number="userInfo.age"/><br/>
            性别：男<input type="radio" name="sex" v-model="userInfo.sex" value="man"/>
                 女<input type="radio" name="sex" v-model="userInfo.sex" value="woman"/><br/>
            爱好：洗澡<input type="checkbox" name="hobby" value="洗澡" v-model="userInfo.hobby"/>
                 洗碗<input type="checkbox" name="hobby" value="洗碗" v-model="userInfo.hobby"/>
                 洗衣服<input type="checkbox" name="hobby" value="洗衣服" v-model="userInfo.hobby"/><br/>
            区域：
                <select v-model="userInfo.city">
                    <option value="">请选择</option>
                    <option value="beijing">北京</option>
                    <option value="shanghai">上海</option>
                    <option value="nanjing">南京</option>
                </select>
                <br/>
            介绍:
                <textarea v-model.lazy="userInfo.tro"></textarea><br/>
            <input type="checkbox" v-model="userInfo.agree"/>同意此<a href="">协议</a>
            <button>提交</button>
        </form>
    </div>
    <script>
        const vm = new Vue({
            el:'#app',
            data: {
                userInfo:{
                    username:'',
                    password:'',
                    age:'',
                    sex:'man',
                    hobby:[],
                    city:'',
                    tro:'',
                    agree: false
                }
            },
            methods:{
                demo(){
                    console.log(this.userInfo);
                }
            }
        })
    </script>
</body>
</html>